.class public Lcom/instagram/android/foursquare/NearbyVenuesService;
.super Landroid/app/IntentService;
.source "NearbyVenuesService.java"


# static fields
.field private static a:Landroid/location/Location;

.field private static b:Lcom/instagram/android/foursquare/d;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 41
    sput-object v0, Lcom/instagram/android/foursquare/NearbyVenuesService;->a:Landroid/location/Location;

    .line 42
    sput-object v0, Lcom/instagram/android/foursquare/NearbyVenuesService;->b:Lcom/instagram/android/foursquare/d;

    return-void
.end method

.method public constructor <init>()V
    .locals 1

    .prologue
    .line 45
    const-string v0, "NearbyVenuesService"

    invoke-direct {p0, v0}, Landroid/app/IntentService;-><init>(Ljava/lang/String;)V

    .line 46
    return-void
.end method

.method private static a()Lcom/instagram/android/foursquare/d;
    .locals 1

    .prologue
    .line 126
    sget-object v0, Lcom/instagram/android/foursquare/NearbyVenuesService;->b:Lcom/instagram/android/foursquare/d;

    return-object v0
.end method

.method private a(Landroid/location/Location;Ljava/lang/String;)V
    .locals 5
    .parameter
    .parameter

    .prologue
    .line 76
    const-string v0, "NearbyVenuesService"

    const-string v1, "Fetching nearby venues"

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->b(Ljava/lang/String;Ljava/lang/String;)V

    .line 78
    new-instance v0, Lcom/instagram/android/foursquare/c;

    invoke-direct {v0, p1, p2}, Lcom/instagram/android/foursquare/c;-><init>(Landroid/location/Location;Ljava/lang/String;)V

    .line 81
    :try_start_0
    invoke-static {}, Lcom/instagram/android/d/a/a;->a()Lcom/instagram/android/d/a/a;

    move-result-object v1

    invoke-virtual {v1, v0}, Lcom/instagram/android/d/a/a;->a(Lcom/instagram/android/d/c/g;)Lch/boye/httpclientandroidlib/HttpResponse;

    move-result-object v1

    .line 82
    if-eqz v1, :cond_3

    .line 83
    invoke-interface {v1}, Lch/boye/httpclientandroidlib/HttpResponse;->getStatusLine()Lch/boye/httpclientandroidlib/StatusLine;

    move-result-object v2

    .line 84
    invoke-interface {v2}, Lch/boye/httpclientandroidlib/StatusLine;->getStatusCode()I

    move-result v3

    const/16 v4, 0xc8

    if-lt v3, v4, :cond_2

    invoke-interface {v2}, Lch/boye/httpclientandroidlib/StatusLine;->getStatusCode()I

    move-result v2

    const/16 v3, 0x12c

    if-ge v2, v3, :cond_2

    .line 85
    invoke-interface {v1}, Lch/boye/httpclientandroidlib/HttpResponse;->getEntity()Lch/boye/httpclientandroidlib/HttpEntity;

    move-result-object v1

    .line 86
    invoke-static {v1}, Lch/boye/httpclientandroidlib/util/EntityUtils;->toString(Lch/boye/httpclientandroidlib/HttpEntity;)Ljava/lang/String;

    move-result-object v1

    .line 88
    invoke-virtual {v0, v1}, Lcom/instagram/android/foursquare/c;->a(Ljava/lang/String;)Lcom/instagram/android/foursquare/d;

    move-result-object v0

    .line 89
    invoke-virtual {v0}, Lcom/instagram/android/foursquare/d;->c()Z

    move-result v1

    if-eqz v1, :cond_1

    .line 90
    const-string v1, "NearbyVenuesService"

    const-string v2, "Successfully fetched nearby venues"

    invoke-static {v1, v2}, Lcom/facebook/e/a/a;->b(Ljava/lang/String;Ljava/lang/String;)V

    .line 91
    if-nez p2, :cond_0

    .line 92
    invoke-static {v0, p1}, Lcom/instagram/android/foursquare/NearbyVenuesService;->a(Lcom/instagram/android/foursquare/d;Landroid/location/Location;)V

    .line 94
    :cond_0
    invoke-direct {p0, v0}, Lcom/instagram/android/foursquare/NearbyVenuesService;->a(Lcom/instagram/android/foursquare/d;)V

    .line 111
    :goto_0
    return-void

    .line 97
    :cond_1
    const-string v0, "NearbyVenuesService"

    const-string v1, "Nearby venue list is empty for search"

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->b(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 110
    :goto_1
    const/4 v0, 0x0

    invoke-direct {p0, v0}, Lcom/instagram/android/foursquare/NearbyVenuesService;->a(Lcom/instagram/android/foursquare/d;)V

    goto :goto_0

    .line 100
    :cond_2
    :try_start_1
    const-string v0, "NearbyVenuesService"

    const-string v1, "Failed to fetch nearby venues: status code is not 2xx."

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->e(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_1

    .line 105
    :catch_0
    move-exception v0

    .line 106
    const-string v1, "NearbyVenuesService"

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "Failed to fetch nearby venues: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v0}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v1, v0}, Lcom/facebook/e/a/a;->e(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_1

    .line 103
    :cond_3
    :try_start_2
    const-string v0, "NearbyVenuesService"

    const-string v1, "Failed to receive response (no network connection?)"

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->e(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_2
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0

    goto :goto_1
.end method

.method private a(Lcom/instagram/android/foursquare/d;)V
    .locals 3
    .parameter

    .prologue
    .line 114
    new-instance v0, Landroid/content/Intent;

    const-string v1, "com.instagram.android.creation.NearbyVenuesFragment.venuesFetched"

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 116
    if-eqz p1, :cond_0

    .line 117
    const-string v1, "requestId"

    invoke-virtual {p1}, Lcom/instagram/android/foursquare/d;->b()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 118
    const-string v1, "venues"

    invoke-virtual {p1}, Lcom/instagram/android/foursquare/d;->a()Ljava/util/ArrayList;

    move-result-object v2

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/io/Serializable;)Landroid/content/Intent;

    .line 119
    const-string v1, "isFoursquareLocation"

    invoke-virtual {p1}, Lcom/instagram/android/foursquare/d;->d()Z

    move-result v2

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Z)Landroid/content/Intent;

    .line 122
    :cond_0
    invoke-static {v0}, Lcom/instagram/n/d;->a(Landroid/content/Intent;)Z

    .line 123
    return-void
.end method

.method private static a(Lcom/instagram/android/foursquare/d;Landroid/location/Location;)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 130
    sput-object p0, Lcom/instagram/android/foursquare/NearbyVenuesService;->b:Lcom/instagram/android/foursquare/d;

    .line 131
    sput-object p1, Lcom/instagram/android/foursquare/NearbyVenuesService;->a:Landroid/location/Location;

    .line 132
    return-void
.end method


# virtual methods
.method public onCreate()V
    .locals 0

    .prologue
    .line 50
    invoke-super {p0}, Landroid/app/IntentService;->onCreate()V

    .line 51
    return-void
.end method

.method protected onHandleIntent(Landroid/content/Intent;)V
    .locals 4
    .parameter "intent"

    .prologue
    .line 55
    const-string v0, "location"

    invoke-virtual {p1, v0}, Landroid/content/Intent;->getParcelableExtra(Ljava/lang/String;)Landroid/os/Parcelable;

    move-result-object v0

    check-cast v0, Landroid/location/Location;

    .line 56
    const-string v1, "searchString"

    invoke-virtual {p1, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    .line 58
    if-nez v0, :cond_0

    .line 59
    const-string v0, "NearbyVenuesService"

    const-string v1, "Cannot query venues for null location"

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->e(Ljava/lang/String;Ljava/lang/String;)V

    .line 60
    const/4 v0, 0x0

    invoke-direct {p0, v0}, Lcom/instagram/android/foursquare/NearbyVenuesService;->a(Lcom/instagram/android/foursquare/d;)V

    .line 73
    :goto_0
    return-void

    .line 65
    :cond_0
    if-nez v1, :cond_1

    sget-object v2, Lcom/instagram/android/foursquare/NearbyVenuesService;->a:Landroid/location/Location;

    if-eqz v2, :cond_1

    sget-object v2, Lcom/instagram/android/foursquare/NearbyVenuesService;->a:Landroid/location/Location;

    invoke-virtual {v0, v2}, Landroid/location/Location;->distanceTo(Landroid/location/Location;)F

    move-result v2

    const/high16 v3, 0x41a0

    cmpg-float v2, v2, v3

    if-gez v2, :cond_1

    .line 67
    const-string v0, "NearbyVenuesService"

    const-string v1, "Returning cached nearby venues"

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->b(Ljava/lang/String;Ljava/lang/String;)V

    .line 68
    invoke-static {}, Lcom/instagram/android/foursquare/NearbyVenuesService;->a()Lcom/instagram/android/foursquare/d;

    move-result-object v0

    invoke-direct {p0, v0}, Lcom/instagram/android/foursquare/NearbyVenuesService;->a(Lcom/instagram/android/foursquare/d;)V

    goto :goto_0

    .line 72
    :cond_1
    invoke-direct {p0, v0, v1}, Lcom/instagram/android/foursquare/NearbyVenuesService;->a(Landroid/location/Location;Ljava/lang/String;)V

    goto :goto_0
.end method
